﻿using Halcon二次开发.Controller.数据加载与保存;
using Halcon二次开发.Controller.结果分析工具;
using Halcon二次开发.Model.储放所有单例.储存每个单例界面;
using Halcon二次开发.Model.自定义控件;
using Halcon二次开发.View.距离转换工具;
using Halcon二次开发.View.卡尺;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Halcon二次开发.View.结果分析工具
{
    public partial class AnalyseResultForms : Form
    {
        public AnalyseControl controller=null;
        public string nodeName;
        HwindowFlowNodeUrseControl hwindowFlowNode;
        public AnalyseResultForms(string name, HwindowFlowNodeUrseControl hwindowFlowNode)
        {
            this.nodeName = name;
            this.hwindowFlowNode = hwindowFlowNode;
            InitializeComponent();
            controller= new AnalyseControl(this);
            comboBox1.SelectedIndex = 1;
        }
        public void GetName(string nodeName)
        {
            this.nodeName = nodeName;
        }
        /// <summary>
        /// 反射调用的方法，请不要修改
        /// </summary>
        /// <param name="path">Json文件的路径</param>
        /// <param name="addres">节点</param>
        public void SetJsonPaths(string path, string addres)
        {
            string paths = path + "\\" + "界面数据\\" + nodeName + "\\" + addres + "数据.json";
            //调用存储方法
            new LoadData().LoadDatas(paths, this);
        }

        private void AnalyseResultForms_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.Hide();
            e.Cancel = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //结果分析
                controller.HideIntputArrays.Clear();
                controller.HideIntputArrays.AddRange((((this.Parent as TabPage).Parent as TabControl).GetControl(1).Tag as DistanceToolForm).controller.HideOutputArrayDistances);//  距离转换工具的数据

                if (comboBox1.Text.Trim() == "打开")
                {
                    controller.Run();
                }
            }
            catch (Exception ex)
            {
                (FormDb.Db["Form1"] as Form1).textBox1.AppendText(this.Name + ":" + ex.Message + "\r\n");
            }
        }
        /// <summary>
        /// 打开分析功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.Text.Trim() == "打开")
            {
                groupBox1.Enabled = true;
            }else if(comboBox1.Text.Trim()=="关闭")
            {
                groupBox1.Enabled = false;
            }
        }
        //分析工具
    }
}
